<template>
  <div
    style="margin-top: 1px;min-height: 100%;"
    class="main-div"
  >
    <Spin v-show="isSpinShow" fix size="large"/>
    <el-tabs v-model="activeName" @tab-click="handleTabClick">
      <el-tab-pane label="基本信息" name="form">
        <div v-if="multiInstanceTaskBtns && multiInstanceTaskBtns.length>0">
          <Button v-for="item in taskSequence" type="primary" style="margin-bottom: 2px;margin-right: 15px;"
                  @click="action(item,item.alias)">{{ item.name }}
          </Button>

          <span v-for="item in multiInstanceTaskBtns">

            <Button style="margin-bottom: 2px;margin-right: 15px;" type="primary"
                    @click="action(item)">{{ item.btnName }}</Button>
          </span>

        </div>

        <div v-if="taskBtns.length>0">
          <Button v-for="item in taskSequence" type="primary" style="margin-bottom: 2px;margin-right: 15px;"
                  @click="action(item,'sequence')">{{ item.name }}
          </Button>

          <span v-for="item in taskBtns">

            <Button type="primary" style="margin-bottom: 2px;margin-right: 15px;"
                    @click="action(item)">{{ item.btnName }}</Button>
          </span>
          <span>
            <Button type="primary" style="margin-bottom: 2px;margin-right: 15px;" @click="go">
              <Icon type="md-close"/>关闭
            </Button>

          </span>

        </div>
        <span v-else>
        <Button v-for="item in taskSequence" type="primary" style="margin-bottom: 2px;margin-right: 15px;"
                @click="action(item,'sequence')">{{ item.name }}</Button>

          <Button
            type="primary"
            style="margin-bottom: 2px;margin-right: 15px;"
            @click="action('agree')"


          >

            办理</Button>
          <Button type="primary" style="margin-bottom: 2px;margin-right: 15px;" @click="action('informed')"

                  class="xr-btn--green"
          >传阅
          </Button>

          <Button
            type="primary"
            style="margin-bottom: 2px;margin-right: 15px;"
            @click="action('transferTask')"
          >转办
          </Button>
<!--          <Button-->
<!--            type="primary"-->
<!--            style="margin-bottom: 2px;margin-right: 15px;"-->
<!--            @click="action('transactionUrge')"-->
<!--          >特事特办-->
<!--          </Button>-->
          <Button
            type="primary"
            style="margin-bottom: 2px;margin-right: 15px;"
            class="xr-btn--orange"
            @click="action('backToNode')"
          >退回
          </Button>
          <Button
            class="xr-btn--red "
            type="primary" style="margin-bottom: 2px;margin-right: 15px;" @click="action('invalid')">作废
          </Button>
            <Button type="primary" style="margin-bottom: 2px;margin-right: 15px;" @click="action('flowImage')">流程图
          </Button>
             <Button
               type="primary"
               style="margin-bottom: 2px;margin-right: 15px;"
               @click="action('approvalHistory')"
             >审批历史
          </Button>
<!--          <Button-->
<!--            type="primary"-->
<!--            style="margin-bottom: 2px;margin-right: 15px;"-->
<!--            @click="action('revisit')"-->
<!--          >流程回放-->
<!--          </Button>-->
          <Button type="primary" style="margin-bottom: 2px;margin-right: 15px;" @click="action('headmap')">热力图
          </Button>
             <el-dropdown
               trigger="click"
               @command="handleCommand">
              <el-button icon="el-icon-more" />
              <el-dropdown-menu slot="dropdown">
                <el-dropdown-item command="addNode">添加临时任务</el-dropdown-item>
                <el-dropdown-item command="addSignNode">添加会签</el-dropdown-item>
                <el-dropdown-item command="headmap">热力图</el-dropdown-item>
                <el-dropdown-item command="transactionUrge">特事特办</el-dropdown-item>
                <el-dropdown-item command="print">打印</el-dropdown-item>
              </el-dropdown-menu>
            </el-dropdown>

<!--          <Button type="primary" style="margin-bottom: 2px;margin-right: 15px;" @click="action('addNode')">添加临时任务-->
<!--          </Button>-->
<!--          <Button-->
<!--            type="primary"-->
<!--            style="margin-bottom: 2px;margin-right: 15px;"-->
<!--            @click="action('addSignNode')"-->
<!--          >添加会签-->
<!--          </Button>-->


<!--          <Button-->
<!--            type="primary"-->
<!--            style="margin-bottom: 2px;margin-right: 15px;"-->
<!--            @click="action('print')"-->
<!--          >打印-->
<!--          </Button>-->

<!--          <Button type="primary" style="margin-bottom: 2px;margin-right: 15px;" @click="go">-->
<!--            <Icon type="md-close"/>关闭-->
<!--          </Button>-->

        </span>
        <el-dialog
          title="转办"
          :visible.sync="transferTask.model"
          :close-on-click-modal="false"
          :append-to-body="true"
          :modal-append-to-body="true"

          width="50%">
          <div>

            <Form ref="transferTask" :model="transferTask" :label-width="120" :rules="transferTaskRuleValidate">
              <FormItem label="备注/意见" prop="option">
                <Input v-model="transferTask.option" type="textarea" :autosize="{minRows: 2,maxRows: 5}"
                       maxlength="60" show-word-limit/>
              </FormItem>
              <FormItem label="转办人">
                <Button
                  v-if="singleUserData!=null && singleUserData.userNo!=null"
                  v-model="singleUserData"
                  type="primary"
                  style="margin-left: 2px"
                  color="primary"
                  @click="delSingleUsers"
                >
                  {{ singleUserData.fullname }} &nbsp;<Icon type="md-close"/>

                </Button>
                <Button type="error" @click="selectSingleShowUsers">
                  <Icon type="ios-contact"/>
                  处理人
                </Button>

              </FormItem>

            </Form>

          </div>
          <div slot="footer">
            <el-button type="primary" @click="transferTaskHandler" :loading="loading">确定</el-button>
            <el-button @click="handleReset('transferTask')">取消</el-button>

          </div>
        </el-dialog>



        <user-single-dialog
          :single-show.sync="singleShow"
          :on-ok="confirmDialogSingleEvent"
          :exist-data="singleUserData"
        />
        <user-multiple-dialog
          :on-ok="confirmDialogEvent"
          :show.sync="show"
          :exist-data="existData"
          :node-index="task.nodeIndex"
          :alias="alias"
        />

        <el-dialog
          title="传阅表单"
          :visible.sync="informed.informed"
          :close-on-click-modal="false"
          :append-to-body="true"
          :modal-append-to-body="true"

          width="50%">
          <div>

            <Form ref="informed" :model="informed" :label-width="120" :rules="informedRuleValidate">
              <FormItem label="任务标题" prop="taskTitle">
                <el-input v-model="informed.taskTitle"/>
              </FormItem>
              <FormItem label="备注/意见" prop="opinion">
                <Input maxlength="60" show-word-limit v-model="informed.opinion" type="textarea"
                       :autosize="{minRows: 2,maxRows: 5}"/>

              </FormItem>
              <FormItem label="传阅人" prop="usersInfo">
                <Button
                  v-for="(item,index) in informed.usersInfo"
                  v-model="informed.usersInfo"
                  type="primary"
                  style="margin-left: 2px"
                  color="primary"
                  @click="delCommonUsers(index)"
                >
                  {{ item.fullname }} &nbsp;<Icon type="md-close"/>

                </Button>
                <Button type="error" @click="selectInformedUsers">
                  <Icon type="ios-contact"/>
                  处理人
                </Button>

              </FormItem>

            </Form>


          </div>
          <div slot="footer">
            <el-button type="primary" @click="informedHandler" :loading="loading">确定</el-button>
            <el-button @click="handleReset('informed')">取消</el-button>
          </div>
        </el-dialog>


        <el-dialog
          title="备注/意见"
          :visible.sync="handlerSequenceModel"
          :close-on-click-modal="false"
          :append-to-body="true"
          :modal-append-to-body="true"

          width="50%">
          <div>
            <Form ref="taskSequenceForm" :model="taskSequenceForm" :label-width="130"
                  :rules="taskSequenceRuleValidate">

              <FormItem label="下一个节点" prop="nextNode">
                <Tag v-for="item in sequenceNode" size="large" color="primary">{{ item.taskName }}</Tag>
              </FormItem>
              <FormItem v-for="(item,index) in sequenceNode" :label="item.taskName" prop="usersIds">
                <Button
                  v-for="(users,userIndex) in item.extObj"
                  v-model="task.usersIds"
                  size="small"
                  type="primary"
                  style="margin-left: 2px"
                  @click="delSequenceUsers(index,userIndex)"
                >{{ users.fullname }}&nbsp;<Icon
                  type="md-close"
                />
                </Button>

                <p>
                  <Button type="error" @click="selectSequenceUsers(index)">
                    <Icon type="ios-contact"/>

                  </Button>
                </p>

              </FormItem>

              <FormItem v-model="taskSequenceForm.priority" label="优先级" prop="priority">
                <el-radio v-model="taskSequenceForm.priority" label="50">无</el-radio>
                <el-radio v-model="taskSequenceForm.priority" label="150">高</el-radio>
                <el-radio v-model="taskSequenceForm.priority" label="100">中</el-radio>
                <el-radio v-model="taskSequenceForm.priority" label="80">低</el-radio>

              </FormItem>

              <FormItem label="任务标题" prop="taskTitle">
                <el-input v-model="taskSequenceForm.taskTitle" clearable/>
              </FormItem>
              <FormItem label="备注/意见" prop="opinion">
                <Input v-model="taskSequenceForm.opinion" clearable type="textarea"
                       :autosize="{minRows: 2,maxRows: 5}"></Input>

              </FormItem>

            </Form>

          </div>
          <div slot="footer">
            <el-button type="primary" @click="agreeTaskSequenceHandler('taskSequence')" :loading="loading">确定
            </el-button>
            <el-button @click="handleReset('taskSequence')">取消</el-button>
          </div>
        </el-dialog>


        <el-dialog
          title="备注/意见"
          :visible.sync="handlerModel"
          :close-on-click-modal="false"
          :append-to-body="true"
          :modal-append-to-body="true"

          width="50%">
          <div>

            <Form ref="task" :model="task" :label-width="130" :rules="ruleValidate">

              <FormItem label="下一个节点" prop="nextNode">
                <Tag v-for="item in task.nextNode" v-model="nextNode" size="large" color="primary">{{ item.taskName
                  }}
                </Tag>
              </FormItem>
              <FormItem v-for="(item,index) in task.nextNode" :label="item.taskName" prop="usersIds">
                <Button
                  v-for="(users,userIndex) in item.extObj"
                  v-model="task.usersIds"
                  size="small"
                  type="primary"
                  style="margin-left: 2px"
                  @click="delUsers(index,userIndex)"
                >{{ users.fullname }}&nbsp;<Icon
                  type="md-close"
                />
                </Button>

                <p>
                  <Button type="error" @click="selectUsers(index)">
                    <Icon type="ios-contact"/>

                  </Button>
                </p>

              </FormItem>
              <FormItem v-model="task.priority" label="优先级" prop="priority">
                <el-radio v-model="task.priority" label="50">无</el-radio>
                <el-radio v-model="task.priority" label="150">高</el-radio>
                <el-radio v-model="task.priority" label="100">中</el-radio>
                <el-radio v-model="task.priority" label="80">低</el-radio>

              </FormItem>

              <FormItem label="任务标题" prop="taskTitle">
                <el-input v-model="task.taskTitle" clearable/>
              </FormItem>
              <FormItem label="备注/意见" prop="opinion">
                <Input maxlength="60" show-word-limit v-model="task.opinion" clearable type="textarea"
                       :autosize="{minRows: 2,maxRows: 5}"/>

              </FormItem>
              <FormItem label="最终意见" prop="opinion">
                <Select v-model="task.bpmVar" style="width:200px">
                  <Option v-for="item in bpmVarList" :value="item.code" :key="item.code">{{ item.name }}</Option>
                </Select>

              </FormItem>
              <FormItem label="常用语" v-if="approval && approval.length>0" >
                <Tag  v-for="(item ,index) in approval" color="primary"  type="border" @click.native="selectTag(item)">{{item.content}}</Tag>


              </FormItem>
            </Form>

          </div>
          <div slot="footer">
            <el-button type="primary" @click="agreeHandler('task')" :loading="loading">确定</el-button>
            <el-button @click="handleReset('task')">取消</el-button>
          </div>
        </el-dialog>

        <el-dialog
          title="备注/意见"
          :visible.sync="agreeAdHocSubProcess.show"
          :close-on-click-modal="false"
          :append-to-body="true"
          :modal-append-to-body="true"

          width="50%">
          <div>

            <Form ref="agreeAdHocSubProcess" :model="agreeAdHocSubProcess" :label-width="120" :rules="ruleValidate">
              <Alert banner closable type="warning">下一个节点勾选那些，实例会创建那些节点。所选择的节点必须设置处理人...</Alert>
              <FormItem label="下一个节点">
                <el-checkbox-group v-model="agreeAdHocSubProcess.nextNodeName" @change="handleCheckedNextNodeChange">

                  <el-checkbox v-for="item in agreeAdHocSubProcess.nextNodeNameOptions"

                               :label="item"
                               :key="item"
                  >
                    {{item}}
                  </el-checkbox>
                </el-checkbox-group>


              </FormItem>
              <FormItem v-for="(item,index) in agreeAdHocSubProcess.nextNode" :label="item.taskName" prop="usersIds">
                <Button
                  v-for="(users,userIndex) in item.extObj"
                  v-model="agreeAdHocSubProcess.usersIds"
                  size="small"
                  type="primary"
                  style="margin-left: 2px"
                  @click="delUsers(index,userIndex)"
                >{{ users.fullname }}&nbsp;<Icon
                  type="md-close"
                />
                </Button>

                <p>
                  <Button type="error" @click="selectAgreeAdHocSubProcessUsers(index)">
                    <Icon type="ios-contact"/>
                  </Button>
                </p>

              </FormItem>
              <FormItem v-model="agreeAdHocSubProcess.priority" label="优先级" prop="priority">
                <el-radio v-model="agreeAdHocSubProcess.priority" label="50">无</el-radio>
                <el-radio v-model="agreeAdHocSubProcess.priority" label="150">高</el-radio>
                <el-radio v-model="agreeAdHocSubProcess.priority" label="100">中</el-radio>
                <el-radio v-model="agreeAdHocSubProcess.priority" label="80">低</el-radio>

              </FormItem>

              <FormItem label="任务标题" prop="taskTitle">
                <el-input v-model="agreeAdHocSubProcess.taskTitle"/>
              </FormItem>
              <FormItem label="备注/意见" prop="option">
                <Input maxlength="60" show-word-limit v-model="agreeAdHocSubProcess.option" type="textarea"
                       :autosize="{minRows: 2,maxRows: 5}"/>

              </FormItem>

            </Form>

          </div>
          <div slot="footer">
            <el-button type="primary" @click="agreeAdHocSubProcessHandle('agreeAdHocSubProcess')" :loading="loading">
              确定
            </el-button>
            <el-button @click="handleReset('agreeAdHocSubProcess')">取消</el-button>

          </div>
        </el-dialog>


        <el-dialog
          title="热力图"
          :visible.sync="headMap.show"
          :close-on-click-modal="false"
          :append-to-body="true"
          :modal-append-to-body="true"

          width="85%">
          <iframe
            id="iframe"
            width="100%"
            style="min-height: 600px"
            height="100%"
            frameborder="0"
            align="center"
            allowfullscreen="true"
            allow="autoplay"
            :src="headMap.src"
          />
          <div slot="footer"/>
        </el-dialog>



        <el-dialog
          title="意见"
          :visible.sync="opinion.show"
          :close-on-click-modal="false"
          :append-to-body="true"
          :modal-append-to-body="true"

          width="85%">
          <Table
            ref="selection"
            highlight-row
            height="450"
            :columns="opinion.tableColumns"
            :data="opinion.tableData"
            style="padding-left: 10px;padding-top: 10px"
          />
          <div slot="footer"/>
        </el-dialog>


        <el-dialog
          title="流程图"
          :visible.sync="flowImage.show"
          :close-on-click-modal="false"
          :append-to-body="true"
          :modal-append-to-body="true"

          width="85%">
          <iframe
            id="flowImageframe"
            width="100%"
            style="min-height: 600px"
            height="100%"
            frameborder="0"
            align="center"
            allowfullscreen="true"
            allow="autoplay"
            :src="flowImage.src"
          />
          <div slot="footer"/>
        </el-dialog>




        <el-dialog
          title="退回"
          :visible.sync="backToNodeForm.show"
          :close-on-click-modal="false"
          :append-to-body="true"
          :modal-append-to-body="true"

          width="50%">
          <Form ref="backToNodeForm" :model="backToNodeForm" :label-width="120" :rules="backToNodFormRuleValidate">

            <FormItem label="退回节点" prop="newActivityId">
              <Select v-model="backToNodeForm.newActivityId" style="width:200px" @on-change="backToNodeChange">
                <Option v-for="item in backToNodeForm.nodeArray" :key="item.id" :value="item.id">{{ item.name }}
                </Option>
              </Select>
              <Button type="error" @click="freedomChoice">
                自由选择
              </Button>
            </FormItem>
            <FormItem label="处理人">
              <Button
                v-if="singleUserData!=null && singleUserData.userNo!=null"
                v-model="singleUserData"
                type="primary"
                style="margin-left: 2px"
                color="primary"
                @click="delSingleUsers"
              >
                {{ singleUserData.fullname }} &nbsp;<Icon type="md-close"/>

              </Button>
              <Button type="error" @click="selectSingleShowUsers">
                <Icon type="ios-contact"/>
                处理人
              </Button>

            </FormItem>
            <FormItem v-model="backToNodeForm.priority" label="优先级" prop="priority">
              <el-radio v-model="backToNodeForm.priority" label="50">无</el-radio>
              <el-radio v-model="backToNodeForm.priority" label="150">高</el-radio>
              <el-radio v-model="backToNodeForm.priority" label="100">中</el-radio>
              <el-radio v-model="backToNodeForm.priority" label="80">低</el-radio>

            </FormItem>

            <FormItem label="任务标题" prop="taskTitle">
              <el-input v-model="backToNodeForm.taskTitle"/>
            </FormItem>
            <FormItem label="备注/意见" prop="option">
              <Input maxlength="60" show-word-limit v-model="backToNodeForm.option" type="textarea"
                     :autosize="{minRows: 2,maxRows: 5}"/>

            </FormItem>

          </Form>
          <div slot="footer">


            <el-button type="primary" @click="backToNodeHandler('backToNode')" :loading="loading">确定</el-button>
            <el-button @click="handleReset('backToNode')">取消</el-button>


          </div>
        </el-dialog>


        <el-dialog
          title="特事特办"
          :visible.sync="transactionUrge.show"
          :close-on-click-modal="false"
          :append-to-body="true"
          :modal-append-to-body="true"

          width="50%">
          <Form ref="transactionUrge" :model="transactionUrge" :label-width="120"
                :rules="transactionUrgeRuleValidate">

            <FormItem label="选择" prop="newActivityId">
              <Select v-model="transactionUrge.newActivityId" style="width:200px">
                <Option v-for="item in transactionUrgeData.nodeArray" :key="item.id" :value="item.id">{{ item.name
                  }}
                </Option>
              </Select>

            </FormItem>
            <FormItem label="处理人">
              <Button
                v-if="singleUserData!=null && singleUserData.userNo!=null"
                v-model="singleUserData"
                type="primary"
                style="margin-left: 2px"
                color="primary"
                @click="delSingleUsers"
              >
                {{ singleUserData.fullname }} &nbsp;<Icon type="md-close"/>

              </Button>
              <Button type="error" @click="selectSingleShowUsers">
                <Icon type="ios-contact"/>
                处理人
              </Button>

            </FormItem>
            <FormItem label="备注/意见" prop="option">
              <Input v-model="transactionUrge.option" type="textarea" :autosize="{minRows: 2,maxRows: 5}"
                     maxlength="60" show-word-limit/>

            </FormItem>
            <FormItem label="任务标题" prop="taskTitle">
              <el-input v-model="transactionUrge.taskTitle"/>
            </FormItem>

            <FormItem v-model="transactionUrge.priority" label="优先级" prop="priority">
              <el-radio v-model="transactionUrge.priority" label="50">无</el-radio>
              <el-radio v-model="transactionUrge.priority" label="150">高</el-radio>
              <el-radio v-model="transactionUrge.priority" label="100">中</el-radio>
              <el-radio v-model="transactionUrge.priority" label="80">低</el-radio>

            </FormItem>

          </Form>
          <div slot="footer">

            <el-button type="primary" @click="transactionUrgeHandler('transactionUrge')" :loading="loading">确定
            </el-button>
            <el-button @click="handleReset('transactionUrge')">取消</el-button>


          </div>
        </el-dialog>

        <el-dialog
          title="添加临时节点"
          :visible.sync="addNode.show"
          :close-on-click-modal="false"
          :append-to-body="true"
          :modal-append-to-body="true"

          width="50%">
          <Form ref="addNode" :model="addNode" :label-width="120" :rules="addNodeRuleValidate">

            <FormItem label="目标节点" prop="nextId">
              <Select v-model="addNode.nextId" style="width:200px">
                <Option v-for="item in transactionUrgeData.nodeArray" :key="item.id" :value="item.id">{{ item.name
                  }}
                </Option>
              </Select>

            </FormItem>
            <FormItem label="处理人">
              <Button
                v-if="singleUserData!=null && singleUserData.userNo!=null"
                v-model="singleUserData"
                type="primary"
                style="margin-left: 2px"
                color="primary"
                @click="delSingleUsers"
              >
                {{ singleUserData.fullname }} &nbsp;<Icon type="md-close"/>

              </Button>
              <Button type="error" @click="selectSingleShowUsers">
                <Icon type="ios-contact"/>
                处理人
              </Button>

            </FormItem>
            <FormItem label="任务名称" prop="userTaskName">
              <Input v-model="addNode.userTaskName"/>
            </FormItem>
          </Form>
          <div slot="footer">

            <el-button type="primary" @click="addNodeHandler('addNode')" :loading="loading">确定</el-button>
            <el-button @click="handleReset('addNode')">取消</el-button>

          </div>
        </el-dialog>


        <el-dialog
          title="添加会签节点"
          :visible.sync="addSign.show"
          :close-on-click-modal="false"
          :append-to-body="true"
          :modal-append-to-body="true"

          width="50%">
          <Form ref="addSign" :model="addSign" :label-width="120" :rules="addSignRuleValidate">

            <FormItem label="目标节点" prop="nextId">
              <Select v-model="addSign.nextId" style="width:200px">
                <Option v-for="item in transactionUrgeData.nodeArray" :key="item.id" :value="item.id">{{ item.name
                  }}
                </Option>
              </Select>

            </FormItem>

            <FormItem label="加签类型" prop="parallel">
              <RadioGroup v-model="addSign.parallel">
                <Radio label="true">
                  <span>串行</span>
                </Radio>
                <Radio label="false">
                  <span>并行</span>
                </Radio>
              </RadioGroup>

            </FormItem>
            <FormItem label="比例" prop="signScale">
              <Select v-model="addSign.signScale" style="width:200px">
                <Option v-for="item in signType" :key="item.lable" :value="item.lable">{{ item.value }}</Option>
              </Select>

            </FormItem>
            <FormItem label="通过" prop="pass">
              <Select v-model="addSign.pass" style="width:200px">
                <Option value="next">流转后置节点</Option>
                <Option value="pre">回退前置节点</Option>
              </Select>
            </FormItem>
            <FormItem label="拒绝" prop="unPass">
              <Select v-model="addSign.unPass" style="width:200px">
                <Option value="next">流转后置节点</Option>
                <Option value="pre">回退前置节点</Option>
              </Select>
            </FormItem>
            <FormItem label="会签人全部参与" prop="allStrage">
              <RadioGroup v-model="addSign.allStrage">
                <Radio label="true">
                  <span>是</span>
                </Radio>
                <Radio label="false">
                  <span>否</span>
                </Radio>
              </RadioGroup>

            </FormItem>
            <FormItem label="策略" prop="signType">
              <RadioGroup v-model="addSign.signType">
                <Radio label="scale">
                  <span>比例通过制</span>
                </Radio>
              </RadioGroup>

            </FormItem>

            <FormItem label="处理人">

              <Button
                v-for="(item,index) in addSign.usersInfo"
                v-model="addSign.usersInfo"
                type="primary"
                style="margin-left: 2px"
                color="primary"
                @click="delCommonUsers(index)"
              >
                {{ item.fullname }} &nbsp;<Icon type="md-close"/>

              </Button>

              <Button
                v-if="singleUserData!=null && singleUserData.userNo!=null"
                v-model="singleUserData"
                type="primary"
                style="margin-left: 2px"
                color="primary"
                @click="delSingleUsers"
              >
                {{ singleUserData.fullname }} &nbsp;<Icon type="md-close"/>

              </Button>
              <Button type="error" @click="selectAddSignUsers">
                <Icon type="ios-contact"/>
                处理人
              </Button>

            </FormItem>
            <FormItem label="任务名称" prop="userTaskName">
              <Input v-model="addSign.userTaskName"/>
            </FormItem>
          </Form>
          <div slot="footer">

            <el-button type="primary" @click="addSignHandler('addSign')" :loading="loading">确定</el-button>
            <el-button @click="handleReset('addSign')">取消</el-button>


          </div>
        </el-dialog>



        <div v-if="jsonData.config!=null" class="container" style="margin-top: 10px; overflow: auto;max-height: 550px">
          <fm-generate-form
            ref="generateForm"
            :data="jsonData"
            :remote="remoteFuncs"
            :value="editData"
            :remote-option="dynamicData"
            :taskId="processInstanceId"
          />

        </div>

        <el-dialog
          title="添加处理人"
          :visible.sync="addUserTask.model"
          :close-on-click-modal="false"
          :append-to-body="true"
          :modal-append-to-body="true"

          width="50%">
          <div>

            <Form ref="addUserTask" :model="addUserTask" :label-width="120">
              <FormItem label="处理人">
                <Button
                  v-if="singleUserData!=null && singleUserData.userNo!=null"
                  v-model="singleUserData"
                  type="primary"
                  style="margin-left: 2px"
                  color="primary"
                  @click="delSingleUsers"
                >
                  {{ singleUserData.fullname }} &nbsp;<Icon type="md-close"/>

                </Button>
                <Button type="error" @click="selectSingleShowUsers">
                  <Icon type="ios-contact"/>
                  处理人
                </Button>

              </FormItem>

            </Form>

          </div>
          <div slot="footer">
            <el-button type="primary" @click="addUserTaskHandler" :loading="loading">确定</el-button>
            <el-button @click="handleReset('addUserTask')">取消</el-button>

          </div>
        </el-dialog>




      </el-tab-pane>
      <el-tab-pane label="附件" name="attachment">


        <el-form ref="attachmentForm" :model="attachmentForm" label-width="80px">
          <el-row class="table_form">
            <el-col :span="12">
              <el-form-item label="变更人" prop="createBy">
                <el-input v-model="attachmentForm.createBy" :disabled="true"/>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="变更时间" prop="createTime">
                <el-input v-model="attachmentForm.createTime" :disabled="true"/>
              </el-form-item>
            </el-col>
            <el-col :span="24">
              <el-form-item label="变更内容" prop="changeContent">
                <el-input
                  type="textarea"
                  :rows="2"
                  placeholder="请输入变更内容"
                  v-model="attachmentForm.changeContent">
                </el-input>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="附件" prop="code">

                <el-upload
                  class="upload-demo"
                  ref="upload"
                  :before-upload="uploadform"
                  :action="baseUploadURL"
                  :on-preview="handlePreview"
                  :on-remove="handleRemove"
                  :on-success="upFile"
                  :file-list="fileList"
                  :auto-upload="true">
                  <el-button type="primary">上传<i class="el-icon-upload el-icon--right"></i></el-button>

                  <div slot="tip" class="el-upload__tip"></div>
                </el-upload>
              </el-form-item>
            </el-col>
            <el-col :span="24">
              <el-form-item label="" prop="code">

                <el-button size="small" type="success" @click="submitForm">保存</el-button>
              </el-form-item>
            </el-col>
          </el-row>

        </el-form>
        <div class="block" style="margin-left: 15px">
          <el-timeline>
            <el-timeline-item color="#0bbd87" v-for="(item,index) in bpmTaskAttachment " :timestamp="item.createTime"
                              placement="top">
              <el-card>
                <h4>变更人:{{item.createBy}}</h4>
                <p> 变更内容: {{item.changeContent}}</p>
                <p v-for="(item1,index1) in item.bpmTaskAttachmentDetailedList">
                  <el-link type="info" :href="item1.url" target="_blank">{{item1.name}}</el-link>
                </p>
              </el-card>
            </el-timeline-item>
          </el-timeline>
        </div>
      </el-tab-pane>
      <el-tab-pane label="流程进度" name="processing">
        <create-sections
          title="审核信息">
          <template slot="header">
            <el-tooltip
              v-if="flowRemarks"
              :content="flowRemarks"
              effect="dark"
              placement="top">
              <i class="wk wk-help wk-help-tips" style="margin-left: 8px;"/>
            </el-tooltip>
          </template>
          <wk-approval-flow-apply
            :data="wkFlowList"
            style="padding: 15px;"
          />
        </create-sections>
      </el-tab-pane>
      <el-tab-pane label="操作记录" name="log">
        <relative-handle :id="processInstanceId"></relative-handle>
      </el-tab-pane>
    </el-tabs>

    <screenfull ref="screenfull" class="right-menu-item hover-effect"/>
    <Modal :mask-closable="false" v-model="revisit.model" fullscreen title="流程回放" @on-cancel="cancelModel"
           :transfer="false">
      <iframe width="100%" height='100%' style="min-height: 650px" frameborder='0' align='center' allowfullscreen='true'
              allow="autoplay" id='iframe2' :src="revisit.modelerSrc"></iframe>
      <div slot="footer"></div>
    </Modal>

    <Modal
      :mask-closable="false"
      v-model="faWenAdd.model"
      title="收发文备注/意见"
      width="70%"
      :transfer="false"
    >
      <div>
        <Form ref="faWenAddForm" :model="faWenAddForm" :label-width="130">

          <FormItem label="下一个节点" prop="nextNode">
            <Tag v-for="item in faWenAddForm.sequenceNode" size="large" color="primary">{{ item.name }}</Tag>
          </FormItem>
          <FormItem v-for="(item,index) in faWenAddForm.sequenceNode" :label="item.name" prop="usersIds">
            <Button
              v-for="(users,userIndex) in item.ucUsers"
              v-model="task.usersIds"
              size="small"
              type="primary"
              style="margin-left: 2px"
              @click="delFaWenSequenceUsers(index,userIndex)"
            >{{ users.fullname }}&nbsp;<Icon
              type="md-close"
            />
            </Button>
            <p>
              <Button type="error" @click="selectFaWenSequenceUsers(index)">
                <Icon type="ios-contact"/>
              </Button>
            </p>

          </FormItem>
          <FormItem label="是否持有待办">
            <i-switch v-model="faWenAddForm.completed" size="large">
              <span slot="open">是</span>
              <span slot="close">否</span>
            </i-switch>
          </FormItem>


        </Form>

      </div>
      <div slot="footer">
        <el-button type="primary" @click="fawenAddHandler('flw_fawen_add')" :loading="loading">确定
        </el-button>
        <el-button @click="handleReset('flw_fawen_add')">取消</el-button>
      </div>

    </Modal>
  </div>

</template>

<script>
  import {
    listVariable
  } from "@/api/variable/variable";

  import {
    addUserToProcId,
    completeAdHoc,
    completeTask,
    getNextNode,
    getTaskBtn,
    renderAttachmentByTaskId,
    renderByTaskId
  } from '@/api/analy'
  import {
    getApprovalOfMe
  } from "@/api/approval/approval";
  import {
    getNextNodeFaWen,
    getNextNodeAndExecuteActivity,
    completeActivity,
    completeActivityOrNo,
    completeActivitySignOnly,
  } from "@/api/fawen";
  import {addAttachment} from '@/api/loadwfmodule'
  import CreateSections from '@/components/CreateSections'
  import WkApprovalFlowApply from '@/components/Examine/WkApprovalFlowApply'

  import {
    addNodeOperate,
    addSignOperate,
    changeActivity,
    getBackNode,
    getBackNodeUser,
    getOutgoingFlows,
    getTransactionUrge,
    informedTask,
    invalidTask,
    opinionTask,
    saveform,
    transferTask
  } from '@/api/action'
  import {
    getProcess
  } from '@/api/analy'
  import userMultipleDialog from '@/views/components/org/userMultipleDialog'
  import userSingleDialog from '@/views/components/org/userSingleDialog'
  import RelativeHandle from '@/components/RelativeHandle'
  import Screenfull from '@/components/Screenfull'

  import Footer from '../../../common/footer'

  export default {
    name: 'Task',
    components: {
      Footer,
      userMultipleDialog,
      userSingleDialog,
      Screenfull,
      CreateSections,
      WkApprovalFlowApply,
      RelativeHandle
    },

    data() {
      return {
        // 审批信息
        flowRemarks: '',
        wkFlowList: [], // 有值有审批流
        faWenAdd: {
          model:false,
          index:0,
        },
        faWenAddForm:{
          sequenceNode: [],
          completed:true,
          taskId:""
        },

        approval:[],
        baseUploadURL: process.env.VUE_APP_BASE_BPM_API + "/a1bpmn/api/upload/drl",
        viewImageModelerTmpSrc: '',
        fileList: [],
        activeName: 'form',
        attachmentForm: {
          createBy: '',
          id: '',
          createTime: '',
          procDefId: '',
          taskId: '',
          processInstanceId: '',
          changeContent: '',
          modelKey: '',
          file: [],
        },
        loading: false,
        fromIndex: false,
        taskId: '',
        processDefinitionId: '',
        processInstanceId: '',
        tableHeight: '',
        alias: '',
        handlerModel: false,
        handlerSequenceModel: false,
        isSpinShow: true,
        show: false,
        singleShow: false,
        jsonData: {},
        editData: {},
        remoteFuncs: {},
        singleUserData: {},
        dynamicData: {},
        taskBtns: [],
        multiInstanceTaskBtns: [],
        taskSequence: [],
        taskSequenceForm: {
          taskTitle: '',
          userInfo: [],
          taskName: '',
          choose: true,
          taskId: '',
          opinion: '',
          formType: 'inner',
          actionName: '',
          action: '',
          nodeType: '',
          usersIds: [],
          userNames: [],
          nextNode: [],
          chooseNode: '',
          chooseNodeUser: '',
          formData: '',
          nodeIndex: 0,
          priority: '50',

        },
        existData: [],
        nextNode: [],
        sequenceNode: [],
        bpmTaskAttachment: [],
        transferTask:
          {
            usersInfo: {},
            option: '',
            taskId: '',
            show: false,
            model: false
          },
        addUserTask:
          {
            usersInfo: {},
            option: '',
            taskId: '',
            show: false,
            model: false
          },
        revisit:
          {
            model: false,
            modelerSrc:''
          },
        headMap:
          {
            show: false,
            src: '',
            base: process.env.VUE_APP_BASE_BPM_API + '/head-map/index.html?processefinitionId='
          },
        opinion:
          {
            show: false,
            tableColumns: [
              {
                title: '任务名称',
                key: 'nodeName'
              },
              {
                title: '创建时间',
                key: 'createTime'
              },
              {
                title: '审批时间',
                key: 'completeTime'
              },
              {
                title: '执行人',
                render: (h, params) => {
                  var html = '-'
                  var node = this.opinion.tableData[params.index]
                  if (node.a1FlowTaskTrajectoryEntity) {
                    html = node.a1FlowTaskTrajectoryEntity.userName
                  } else {
                    html = node.auditor
                  }
                  if (!html) {
                    if (node.identityLinks) {
                      html = node.identityLinks
                    }

                  }
                  return h('span', html)
                }
              },
              {
                title: '任务标题',
                render: (h, params) => {
                  var html = '-'
                  var node = this.opinion.tableData[params.index]
                  html = node.a1FlowTaskTrajectoryEntity.title
                  return h('span', html)
                }
              },
              {
                title: '备注/意见',
                render: (h, params) => {
                  var html = '-'
                  var node = this.opinion.tableData[params.index]
                  html = node.a1FlowTaskTrajectoryEntity.opinion
                  return h('span', html)
                }
              },
              {
                title: '状态说明',
                render: (h, params) => {
                  var html = '-'
                  var node = this.opinion.tableData[params.index]
                  html = node.a1FlowTaskTrajectoryEntity.statusVal
                  return h('span', html)
                }
              }

            ],
            tableData: []
          },
        flowImage:
          {
            show: false,
            src: '',
            base: process.env.VUE_APP_BASE_BPM_API + '/view/tab.html?fireHoverAction=true&table=false' + '&instId='
          },
        transactionUrge:
          {
            show: false,
            newActivityId: '',
            operate: 'transactionUrge',
            taskTitle: '',
            taskId: '',
            option: '',
            priority: '50',
            usersInfo: {}
          },
        transactionUrgeData: {
          nodeArray: []
        },
        addNode: {
          show: false,
          nextId: '',
          userTaskName: ''
        },
        signType: [
          {lable: '10', value: '10%'},
          {lable: '20', value: '20%'},
          {lable: '30', value: '30%'},
          {lable: '40', value: '40%'},
          {lable: '50', value: '50%'},
          {lable: '60', value: '60%'},
          {lable: '70', value: '70%'},
          {lable: '80', value: '80%'},
          {lable: '90', value: '90%'},
          {lable: '100', value: '100%'}
        ],
        addSign: {
          show: false,
          all: false,
          parallel: 'false',
          allStrage: 'false',
          doUserId: '',
          pass: 'next',
          nextId: '',
          signScale: '',
          signType: 'scale',
          unPass: 'next',
          userTaskName: '',
          usersInfo: []

        },
        sequence: {
          users: []
        },
        addSignRuleValidate: {
          nextId: [
            {required: true, message: '目标节点必须填写', trigger: 'blur'}
          ],
          signType: [
            {required: true, message: '策略必填', trigger: 'blur'}
          ],
          signScale: [
            {required: true, message: '比例必填', trigger: 'blur'}
          ],
          userTaskName: [
            {required: true, message: '任务名称必填', trigger: 'blur'}
          ]
        },
        informed: {
          show: false,
          informed: false,
          usersInfo: [],
          opinion: '',
          taskTitle: '',
          taskId: ''

        },
        agreeAdHocSubProcess: {
          show: false,
          usersIds: [],
          userNames: [],
          nextNode: [],
          nextNodeName: [],
          nextNodeNameOptions: [],
          taskId: "",
          usersInfo: [],
          nodeIndex: 0,
          priority: '50',
          taskTitle: '',
          option: '',
          chooseNode: '',
          chooseNodeUser: '',
        },
        backToNodeForm: {
          show: false,
          usersInfo: [],
          option: '',
          taskTitle: '',
          taskId: '',
          priority: '50',
          newActivityId: '',
          operate: 'backToNode',
          nodeArray: []
        },
        backToNodFormRuleValidate: {
          newActivityId: [
            {required: true, message: '退回节点必须填写', trigger: 'blur'}
          ],
          option: [
            {required: true, message: '意见必须填写', trigger: 'blur'}
          ]
        },
        scopeType: "",
        monitor: false,

        tmpTaskInfo: {taskTitle: '',},
        bpmVarList: [

        ],
        task: {
          taskName: '',
          bpmVar: '',
          taskId: '',
          opinion: '',
          formType: 'inner',
          actionName: '',
          action: '',
          nodeType: '',
          usersIds: [],
          userNames: [],
          nextNode: [],
          chooseNode: '',
          chooseNodeUser: '',
          formData: '',
          nodeIndex: 0,
          priority: '50',
          taskTitle: ''

        },
        ruleValidate: {
          option: [
            {required: true, message: '意见必须填写', trigger: 'blur'}
          ]
        },
        taskSequenceRuleValidate: {
          opinion: [
            {required: true, message: '意见必须填写', trigger: 'blur'}
          ]
        },
        backToNodeRuleValidate: {
          opinion: [
            {required: true, message: '意见必须填写', trigger: 'blur'}
          ]
        },

        informedRuleValidate: {
          taskTitle: [
            {required: true, message: '标题必须填写', trigger: 'blur'}
          ],
          opinion: [
            {required: true, message: '意见必须填写', trigger: 'blur'}
          ]

        },
        transferTaskRuleValidate: {
          usersInfo: [
            {required: true, message: '转办人必须填写', trigger: 'blur'}
          ],
          option: [
            {required: true, message: '意见必须填写', trigger: 'blur'}
          ]

        },
        transactionUrgeRuleValidate: {
          newActivityId: [
            {required: true, message: '节点必须填写', trigger: 'blur'}
          ],
          usersInfo: [
            {required: true, message: '人员必须填写', trigger: 'blur'}
          ],
          option: [
            {required: true, message: '意见必须填写', trigger: 'blur'}
          ]

        },
        addNodeRuleValidate: {
          userTaskName: [
            {required: true, message: '任务名称必填', trigger: 'blur'}
          ],
          nextId: [
            {required: true, message: '目标节点必填', trigger: 'blur'}
          ]

        }
      }
    },
    mount() {

    },

    created() {
      this.activeName = 'form'
      var query = this.$route.query
      var queryTaskId = query.taskId;
      var monitor = query.monitor;
      if (monitor) {
        this.monitor = monitor;
      }
      if (query.taskId) {
        queryTaskId = query.taskId;
      } else {
        queryTaskId = this.taskParam;
        this.fromIndex = true
      }
      this.taskId = queryTaskId
      this.task.taskId = queryTaskId
      this.scopeType = query.scopeType

      this.initData();



    },
    props: {
      taskParam: {
        type: String,
        default: ""
      }
    },
    watch: {
      taskParam() {
        this.activeName = 'form'

        if (this.taskParam) {
          this.taskId = this.taskParam
          this.task.taskId = this.taskParam
          this.fromIndex = true;
          this.initData();

        } else {

          this.jsonData = {}
          this.editData = {}
          this.fromIndex = false;
          this.restartShow()

        }

      },
      jsonData: {
        handler(newValue, oldValue) {
          if (newValue) {
            this.getFormData()
          }
        },
        deep: true
      }
    },

    methods: {
      handleCommand(command) {
        switch (command) {
          case 'addNode':
            this.action('addNode')
            break
          case 'addSignNode':
            this.action('addSignNode')
            break
          case 'headmap':
            this.action('headmap')
            break
          case 'transactionUrge':
            this.action('transactionUrge')
            break
          case 'print':
            this.action('print')
            break
          default:
            return
        }
      },
      /** 查询内置变量列表 */
      getBpmVarList() {
        listVariable({ pageNum: 1,
          pageSize: 1000,}).then(response => {
          this.bpmVarList = response.data;
        });
      },
      cancelModel: function () {
        this.revisit.model = false;

      },
      handleTabClick(tab, event) {
        if (tab.name == 'attachment') {
          this.renderAttachmentByTaskId(this.taskId)

        }
      },
      /** 提交按钮 */
      submitForm() {
        this.$refs["attachmentForm"].validate(valid => {
          var formData = new FormData();//new一个formData事件
          for (var i = 0; i < this.attachmentForm.file.length; i++) {
            formData.append('files', this.attachmentForm.file[i]);
          }
          formData.append("procDefId", this.attachmentForm.procDefId);
          formData.append("changeContent", this.attachmentForm.changeContent);
          formData.append("modelKey", this.modelKey);
          if (this.attachmentForm.id) {
            formData.append("id", this.attachmentForm.id);
          }
          if (this.attachmentForm.taskId) {
            formData.append("taskId", this.attachmentForm.taskId);
          }
          if (this.attachmentForm.processInstanceId) {
            formData.append("processInstanceId", this.attachmentForm.processInstanceId);
          }

          if (valid) {
            addAttachment(formData).then(response => {
              if (response.code == 0) {
                this.attachmentForm.id = response.msg
                this.msgSuccess("操作成功");
              }

            });
          }
        });
      },
      handleRemove(file, fileList) {
        this.attachmentForm.file = fileList
        console.log(file, fileList);
      },
      handlePreview(file) {
        console.log(file);
      },
      uploadform: function (file) {
        if (!this.attachmentForm.file) {
          this.attachmentForm.file = []
        }
        this.attachmentForm.file.push(file)
      },
      /* 上传文件操作 */
      upFile(res, file) {
      },
      restartShow: function () {
        this.handlerModel = false
        this.agreeAdHocSubProcess.show = false
        this.headMap.show = false
        this.opinion.show = false
        this.flowImage.show = false
        this.backToNodeForm.show = false
        this.transactionUrge.show = false
        this.addNode.show = false
        this.addSign.show = false
      },
      initData: function () {
        this.getTaskBtn(this.taskId)
        this.getFlowProcess(this.taskId)
        this.renderByTaskId(this.taskId)
        this.renderAttachmentByTaskId(this.taskId)
        this.renderApproval()

        this.$nextTick(() => {
          try {
            this.$refs['task'].validate((valid) => {
            })
          } catch (e) {

          }
        })
        if (this.scopeType) {

        } else {
          this.getNextNode()
        }
        this.getFormData();
        this.task.opinion = '';
        this.taskSequenceForm.opinion = '';
        this.agreeAdHocSubProcess.opinion = '';
      },
      triggerRuleValidate: function () {

      },
      handleCheckedNextNodeChange: function (data) {
      },
      freedomChoice: function () {
        getTransactionUrge(this.taskId).then((response) => {
          if (response.code == 0) {
            this.backToNodeForm.nodeArray = response.data
          }
        })
      },
      backToNodeChange: function (nodeId) {
        getBackNodeUser(this.taskId, nodeId).then((response) => {
          if (response.code == 0) {
            if (response.data && response.data.length > 0) {
              if (response.data[0].assigneeName && response.data[0].assignee) {
                var assigneeName = response.data[0].assigneeName
                var assignee = response.data[0].assignee
                this.singleUserData = {'userNo': assignee, 'fullname': assigneeName}
                this.backToNodeForm.usersInfo = this.singleUserData
              } else {
                this.singleUserData = {}
                this.backToNodeForm.usersInfo = {}
              }
            } else {
              this.singleUserData = {}
              this.backToNodeForm.usersInfo = {}
            }
          }
        })
      },
      confirmDialogEvent: function (data) {
        if (data) {
          switch (this.alias) {
            case 'agree':// 普通任务正常办理
              this.task.nextNode[this.task.nodeIndex].extObj = data
              break
            case 'informed':
              this.informed.usersInfo = data
              this.existData = data
              break
            case 'transferTask':
              this.transferTask.usersInfo = data
              this.existData = data
              break
            case 'transactionUrge':
              this.transactionUrge.usersInfo = data
              this.existData = data
              break
            case 'agreeAdHocSubProcess':
              this.agreeAdHocSubProcess.nextNode[this.task.nodeIndex].extObj = data
              break
            case 'addSignNode':
              this.addSign.usersInfo = data
              this.existData = data
              break
            case 'sequence':
              this.sequence.users = data
              this.sequenceNode[0].extObj = data
              this.taskSequence.userInfo = data;
              break
            case 'flw_fawen_add'://发文下发任务
              this.existData = data
              this.faWenAddForm.sequenceNode[this.faWenAdd.index].ucUsers=data
              break;
            default:
              this.task.nextNode[this.task.nodeIndex].extObj = data
              break
          }
        }
      },
      confirmDialogSingleEvent: function (data) {
        if (data) {
          this.singleUserData = data
        }
      },
      confirmInformedDialogEvent: function (data) {
        if (data) {
        }
      },

      selectUsers: function (index) {
        this.task.nodeIndex = index

        var users = this.task.nextNode[index].extObj
        this.existData = users
        this.show = true

      },
      selectSequenceUsers: function (index) {
        var users = this.sequenceNode[0].extObj;
        this.existData = []
        if (users) {
          this.existData = users
        }
        this.show = true
      },
      selectFaWenSequenceUsers: function (index) {
        var users = this.faWenAddForm.sequenceNode[index].ucUsers;
        this.alias="flw_fawen_add"
        this.faWenAdd.index=index
        this.existData = []
        if (users) {
          this.existData = users
        }
        this.show = true
      },
      delFaWenSequenceUsers: function (index, userIndex) {
        this.faWenAddForm.sequenceNode[index].ucUsers.splice(userIndex, 1)
      },

      selectAddSignUsers: function () {
        try {
          this.existData = this.addSign.usersInfo;

        } catch (e) {
          this.existData = []
        }
        this.show = true
      },
      selectInformedUsers: function () {
        try {
          this.existData = this.informed.usersInfo;

        } catch (e) {
          this.existData = []
        }
        this.show = true
      },
      selectAgreeAdHocSubProcessUsers: function (index) {
        this.task.nodeIndex = index;
        try {
          this.existData = this.agreeAdHocSubProcess.nextNode[index].extObj

        } catch (e) {
          this.existData = []
        }
        this.show = true
      },
      selectSingleShowUsers: function () {
        this.singleShow = true
      },
      delUsers: function (index, userIndex) {
        this.task.nextNode[index].extObj.splice(userIndex, 1)
      },
      delSequenceUsers: function (index, userIndex) {
        this.sequenceNode[0].extObj.splice(userIndex, 1)
      },
      delCommonUsers: function (index) {
        this.informed.usersInfo.splice(index, 1)
        this.addSign.usersInfo.splice(index, 1)
        this.existData.splice(index, 1)
      },
      delSingleUsers: function (index) {
        this.singleUserData = {}
      },
      getFormData: function () {
        if (this.$refs.generateForm) {
          this.$refs.generateForm.getData().then(data => {
            this.task.formData = JSON.stringify(data)
            return data
          }).catch(e => {
          })
        }

      },
      backToNodeHandler: function () {
        new Promise((resolve, reject) => {
          if (this.singleUserData && this.singleUserData.userNo) {
            this.$refs['backToNodeForm'].validate((valid) => {
              if (valid) {
                const obj = JSON.parse(JSON.stringify(this.backToNodeForm))
                delete (obj['show'])
                delete (obj['nodeArray'])
                delete (obj['usersInfo'])
                obj['userId'] = this.singleUserData.userNo
                obj['userName'] = this.singleUserData.fullname
                obj['taskId'] = this.taskId
                delete (obj['usersInfo'])
                this.loading = true
                changeActivity(obj).then((response) => {
                  if (response.code == 0) {
                    this.go()
                  } else {
                    this.$message({"duration": '800', message: response.msg, type: 'warning', customClass: 'zZindex'});

                  }
                  this.loading = false
                })
              } else {

              }
            })
          } else {
            that.$message({message: '请选择处理人', type: 'warning', customClass: 'zZindex'});
          }
        })
      },
      transactionUrgeHandler: function () {
        new Promise((resolve, reject) => {
          if (this.singleUserData && this.singleUserData.userNo) {
            this.$refs['transactionUrge'].validate((valid) => {
              if (valid) {
                this.changeActivityAction()
              } else {

              }
            })
          } else {
            this.$message({"duration": '800', message: '请选择处理人', type: 'warning', customClass: 'zZindex'});

          }
        })
      },
      afterAddSignHandler: function () {
        this.addSign.all = false
        this.addSign.parallel = 'false'
        this.addSign.allStrage = 'false'
        this.addSign.doUserId = ''
        this.addSign.pass = 'next'
        this.addSign.nextId = ''
        this.addSign.signScale = ''
        this.addSign.signType = 'scale'
        this.addSign.unPass = 'next'
        this.addSign.userTaskName = ''
        this.addSign.usersInfo = []
      },
      addSignHandler: function () {
        this.loading = false;
        new Promise((resolve, reject) => {
          if (this.addSign.usersInfo && this.addSign.usersInfo.length > 0) {
            this.$refs['addSign'].validate((valid) => {
              if (valid) {
                const obj = JSON.parse(JSON.stringify(this.addSign))
                delete (obj['show'])
                obj['taskId'] = this.taskId
                this.loading = true;
                addSignOperate(obj).then((response) => {
                  if (response.code == 0) {
                    this.$message({"duration": '800', message: '操作成功', type: 'success', customClass: 'zZindex'});
                    this.addSign.show = false
                    this.afterAddSignHandler()
                    this.go();
                  } else {
                    this.$message({"duration": '800', message: response.msg, type: 'success', customClass: 'zZindex'});

                  }
                  this.loading = false;
                })
              } else {

              }
            })
          } else {
            this.$message({"duration": '800', message: '请选择处理人', type: 'warning', customClass: 'zZindex'});
          }
        })
      },
      addNodeHandler: function () {
        try {
          this.loading = false;

          new Promise((resolve, reject) => {
            if (this.singleUserData && this.singleUserData.userNo) {
              this.$refs['addNode'].validate((valid) => {
                if (valid) {
                  // addNodeOperate
                  const obj = JSON.parse(JSON.stringify(this.addNode))
                  delete (obj['show'])
                  obj['taskId'] = this.taskId
                  obj['users'] = this.singleUserData.userNo
                  this.loading = true;
                  addNodeOperate(obj).then((response) => {
                    if (response.code == 0) {
                      this.$message({"duration": '800', message: '操作成功', type: 'success', customClass: 'zZindex'});
                      this.addNode.show = false
                      this.go();
                    } else {
                      this.$message({
                        "duration": '800',
                        message: response.msg,
                        type: 'warning',
                        customClass: 'zZindex'
                      });
                    }
                    this.loading = false;
                  })
                } else {

                }
              })
            } else {
              this.$message({"duration": '800', message: '请选择处理人', type: 'warning', customClass: 'zZindex'});

            }
          })
        } finally {
          this.loading = false;

        }

      },
      changeActivityAction: function () {
        this.loading = false;
        const obj = JSON.parse(JSON.stringify(this.transactionUrge))
        delete (obj['show'])
        obj['userId'] = this.singleUserData.userNo
        obj['userName'] = this.singleUserData.fullname
        obj['taskId'] = this.taskId
        delete (obj['usersInfo'])
        this.loading = true;
        changeActivity(obj).then((response) => {
          if (response.code == 0) {
            this.go()
          } else {
            this.$message({"duration": '800', message: response.msg, type: 'warning', customClass: 'zZindex'});

          }
          this.loading = false;
        })
      },
      completeSequenceTask: function () {
        this.loading = false;
        new Promise((resolve, reject) => {
          if (this.sequenceNode[0]) {
            this.taskSequenceForm.chooseNode = this.sequenceNode[0].chooseNode
            this.taskSequenceForm.chooseNodeUser = this.sequenceNode[0].chooseNodeUser
          }

          this.taskSequenceForm.taskId = this.task.taskId;
          this.taskSequenceForm.formData = this.task.formData
          this.loading = true;
          completeTask(this.taskSequenceForm).then((response) => {
            if (response.code == 0) {
              this.handlerSequenceModel = false;
              this.go()
            } else {
              this.$message({"duration": '800', message: response.msg, type: 'warning', customClass: 'zZindex'});

            }
            this.loading = false;

          })
        })
      },
      fawenAddHandler:function(){
        this.loading = false;
        getNextNodeAndExecuteActivity(this.faWenAddForm).then((response) => {
          if (response.code == 0) {
            this.faWenAdd.model = false;
            this.go()
          } else {
            this.$message({"duration": '800', message: response.msg, type: 'warning', customClass: 'zZindex'});

          }

        })


      },
      agreeTaskSequenceHandler: function () {
        //taskSequence
        this.loading = false;
        this.$refs['taskSequenceForm'].validate((valid) => {
          if (valid) {
            var nextNodeStr = ''
            var nextNodeStrUser = ''
            for (var i = 0; i < this.sequenceNode.length; i++) {
              nextNodeStr += this.sequenceNode[i].taskId
              if (i < this.sequenceNode.length - 1) {
                nextNodeStr += ','
              }

              if (this.sequenceNode[i].extObj) {
                for (var j = 0; j < this.sequenceNode[i].extObj.length; j++) {
                  nextNodeStrUser += this.sequenceNode[i].extObj[j].userNo
                  if (j < this.sequenceNode[i].extObj.length - 1) {
                    nextNodeStrUser += ','
                  }
                }
                if (this.sequenceNode.length > 1 && i < this.sequenceNode.length - 1) {
                  nextNodeStrUser += '_'
                }
              }
            }
            if (this.sequenceNode && this.sequenceNode[0]) {
              this.sequenceNode[0].chooseNode = nextNodeStr
              this.sequenceNode[0].chooseNodeUser = nextNodeStrUser
            }
            const that = this
            setTimeout(function () {
              that.completeSequenceTask()
            }, 300)
          } else {
            this.$message({"duration": '800', message: '表单校验不通过', type: 'warning', customClass: 'zZindex'});

          }
        })
      },
      agreeAdHocSubProcessHandle: function () {
        this.loading = false;
        this.$refs['agreeAdHocSubProcess'].validate((valid) => {
          var nextNodeName = this.agreeAdHocSubProcess.nextNodeName
          if (valid) {
            var nextNodeStr = ''
            var nextNodeStrUser = ''
            for (var i = 0; i < this.nextNode.length; i++) {
              var taskName = this.nextNode[i].taskName
              var flag = false;
              for (var j = 0; j < nextNodeName.length; j++) {
                if (nextNodeName[j] == taskName) {
                  flag = true;
                  break
                }
              }
              ;


              if (flag) {
                nextNodeStr += this.nextNode[i].taskId
                if (i < this.nextNode.length - 1) {
                  nextNodeStr += ','
                }

                if (this.nextNode[i].extObj) {
                  for (var j = 0; j < this.nextNode[i].extObj.length; j++) {
                    nextNodeStrUser += this.nextNode[i].extObj[j].userNo
                    if (j < this.nextNode[i].extObj.length - 1) {
                      nextNodeStrUser += ','
                    }
                  }
                  if (this.nextNode.length > 1 && i < this.nextNode.length - 1) {
                    nextNodeStrUser += '_'
                  }
                }
              }
            }

            var userNodeReg = /,$/gi;//
            var userReg = /_$/gi;//
            nextNodeStrUser = nextNodeStrUser.replace(userReg, "");
            nextNodeStr = nextNodeStr.replace(userNodeReg, "");
            this.agreeAdHocSubProcess.chooseNode = nextNodeStr.replace(userReg, "");
            this.agreeAdHocSubProcess.chooseNodeUser = nextNodeStrUser
            const that = this
            setTimeout(function () {
              that.completeAdHoc()
            }, 300)
          } else {
          }
        })
      },
      selectTag(data){
        this.task.opinion=data.content
      },
      agreeHandler: function () {
        this.loading = false;
        this.$refs['task'].validate((valid) => {
          if (valid) {
            var nextNodeStr = ''
            var nextNodeStrUser = ''
            for (var i = 0; i < this.nextNode.length; i++) {
              nextNodeStr += this.nextNode[i].taskId
              if (i < this.nextNode.length - 1) {
                nextNodeStr += ','
              }

              if (this.nextNode[i].extObj) {
                for (var j = 0; j < this.nextNode[i].extObj.length; j++) {
                  nextNodeStrUser += this.nextNode[i].extObj[j].userNo
                  if (j < this.nextNode[i].extObj.length - 1) {
                    nextNodeStrUser += ','
                  }
                }
                if (this.nextNode.length > 1 && i < this.nextNode.length - 1) {
                  nextNodeStrUser += '_'
                }
              }
            }
            this.task.chooseNode = nextNodeStr
            this.task.chooseNodeUser = nextNodeStrUser
            const that = this
            this.loading = true;
            setTimeout(function () {

              that.completeTask();
              that.loading = false;
            }, 300)
          } else {
            this.handlerModel = true
          }
        })
      },
      informedTask: function () {
        this.loading = false;
        new Promise((resolve, reject) => {
          this.informed.taskId = this.taskId
          this.$refs['informed'].validate((valid) => {
            if (valid) {
              this.informedTaskAction()
            } else {

            }
          })
        })
      },
      transferTaskAction: function () {
        this.loading = false;
        new Promise((resolve, reject) => {
          this.transferTask.taskId = this.taskId
          if (this.singleUserData && this.singleUserData.userNo) {
            this.$refs['transferTask'].validate((valid) => {
              if (valid) {
                this.doTransferTaskAction()
              } else {

              }
            })
          } else {
            this.$message({"duration": '800', message: '请选择转办人', type: 'warning', customClass: 'zZindex'});

          }
        })
      },
      addUserTaskAction: function () {
        this.loading = false;
        new Promise((resolve, reject) => {
          this.addUserTask.taskId = this.taskId
          if (this.singleUserData && this.singleUserData.userNo) {
            this.$refs['addUserTask'].validate((valid) => {
              if (valid) {
                this.doAddUserTaskAction()
              } else {

              }
            })
          } else {
            this.$message({"duration": '800', message: '请选择处理人', type: 'warning', customClass: 'zZindex'});

          }
        })
      },
      afterInformedTaskAction: function () {
        this.informed.informed = false
        this.informed.opinion = ''
        this.informedReset()
        this.$message({"duration": '800', message: '传阅成功', type: 'success', customClass: 'zZindex'});
        this.$store.dispatch('user/SetToDoCount')
        this.$refs.screenfull.getRunCommuListCount();
      },
      afterTransferTaskAction: function () {
        this.go()
        this.$store.dispatch('user/SetToDoCount')

      },
      informedTaskAction: function () {
        this.loading = false;
        const obj = JSON.parse(JSON.stringify(this.informed))
        delete (obj['show'])
        delete (obj['informed'])
        this.loading = true;
        informedTask(obj).then((response) => {
          if (response.code == 0) {

            this.afterInformedTaskAction()
          } else {
            this.$message({"duration": '800', message: response.msg, type: 'warning', customClass: 'zZindex'});

          }
          this.loading = false;
        })
      },
      doAddUserTaskAction: function () {
        this.loading = false;
        const obj = JSON.parse(JSON.stringify(this.addUserTask))
        obj['usersInfo'] = this.singleUserData
        delete (obj['show'])
        delete (obj['model'])
        var userNo = obj.usersInfo.userNo;
        var taskId = obj.taskId

        addUserToProcId(taskId, userNo).then((response) => {
          if (response.code == 0) {
            this.$message({"duration": '800', message: '添加处理人', type: 'success', customClass: 'zZindex'});
            this.addUserTask.model = false
            const that = this
            this.loading = true;
            setTimeout(function () {
              that.handleAddUserTaskReset()
              that.afterTransferTaskAction()
              that.loading = false;
            }, 300)
          } else {
            this.$message({"duration": '800', message: response.msg, type: 'warning', customClass: 'zZindex'});


          }
        })
      },
      doTransferTaskAction: function () {
        this.loading = false;
        const obj = JSON.parse(JSON.stringify(this.transferTask))
        obj['usersInfo'] = this.singleUserData
        delete (obj['show'])
        delete (obj['model'])
        transferTask(obj).then((response) => {
          if (response.code == 0) {
            this.$message({"duration": '800', message: '转办成功', type: 'success', customClass: 'zZindex'});
            this.transferTask.model = false
            const that = this
            this.loading = true;
            setTimeout(function () {
              that.afterTransferTaskAction()
              that.loading = false;
            }, 300)
          } else {
            this.$message({"duration": '800', message: response.msg, type: 'warning', customClass: 'zZindex'});


          }
        })
      },
      completeTask: function () {
        this.loading = false;
        new Promise((resolve, reject) => {
          const objB = JSON.parse(JSON.stringify(this.task))
          objB['monitor'] = this.monitor
          delete (objB['usersIds'])
          delete (objB['userNames'])
          delete (objB['nextNode'])

          completeTask(objB).then((response) => {
            if (response.code == 0) {
              this.go()
            } else {
              this.$message({"duration": '800', message: response.msg, type: 'success', customClass: 'zZindex'});

            }
          })
        })
      },
      /**
       * 完成AdHoc任务
       */
      completeAdHoc: function () {
        this.loading = false;
        new Promise((resolve, reject) => {
          const objB = JSON.parse(JSON.stringify(this.agreeAdHocSubProcess))
          delete (objB['usersIds'])
          delete (objB['userNames'])
          delete (objB['nextNode'])
          objB["formData"] = this.task.formData
          objB["taskId"] = this.task.taskId
          objB["opinion"] = objB['option']
          this.loading = true
          completeAdHoc(objB).then((response) => {
            if (response.code == 0) {
              this.go()
            } else {
              this.$message({"duration": '800', message: response.msg, type: 'success', customClass: 'zZindex'});

            }
            this.loading = false
          })
        })
      },
      informedReset() {
        this.informed.informed = false
        this.existData = []
        this.informed.usersInfo = []
      },
      handleReset(name) {
        this.handlerModel = false
        this.informed.informed = false
        this.informed.opinion = ''
        this.informedReset()
        this.loading = false;
        if (name == 'task') {
          this.task.opinion = ""
          this.task.priority = '50'
          this.task.taskTitle = JSON.parse(JSON.stringify(this.tmpTaskInfo)).taskTitle
        }
        if (name == 'transferTask') {
          this.handleTransferTaskReset()
        }
        if (name == 'addUserTask') {
          this.handleAddUserTaskReset()
        }
        if (name == 'flw_fawen_add') {
          this.handleAddFaWenReset()
        }
        if (name == 'addNode') {
          this.handleAddNodeReset()
        }
        if (name == 'transactionUrge') {
          this.handleTransactionUrgeReset()
        }
        if (name == 'addSign') {
          this.handleAddSignReset()
        }
        if (name == 'agreeAdHocSubProcess') {
          this.agreeAdHocSubProcess.show = false;
        }
        if (name == 'backToNode') {
          this.handleBackToNodeReset()
        }
        if (name == 'taskSequence') {
          this.handlerSequenceModel = false
        }
      },
      handleTransferTaskReset() {
        this.transferTask.usersInfo = {}
        this.singleUserData = {}
        this.transferTask.option = ''
        this.transferTask.model = false
      },
      //添加处理人
      handleAddUserTaskReset() {
        this.addUserTask.usersInfo = {}
        this.singleUserData = {}
        this.addUserTask.option = ''
        this.addUserTask.model = false
      },
      handleAddFaWenReset() {
        this.faWenAdd.model = false
        this.faWenAddForm.sequenceNode = []
        this.faWenAdd.index = 0
      },
      handleBackToNodeReset() {
        this.backToNodeForm.usersInfo = {}
        this.backToNodeForm.show = false
        this.backToNodeForm.option = ''
        this.backToNodeForm.newActivityId = ''
        this.singleUserData = {}
      },
      handleTransactionUrgeReset() {
        this.transactionUrge.usersInfo = {}
        this.singleUserData = {}
        this.transactionUrge.newActivityId = ''
        this.transactionUrge.option = ''
        this.transactionUrge.show = false
      },
      handleAddNodeReset() {
        this.singleUserData = {}
        this.addNode.nextId = ''
        this.addNode.userTaskName = ''
        this.addNode.show = false
      },
      handleAddSignReset() {
        this.addSign.usersInfo = []
        this.addSign.userTaskName = ''
        this.addSign.nextId = ''
        this.addSign.doUserId = ''
        this.addSign.show = false
        this.existData = []
      },
      informedHandler() {
        this.informedTask()
      },
      transferTaskHandler() {
        this.transferTaskAction()
      },
      addUserTaskHandler() {
        this.addUserTaskAction()
      },

      action: function (action, type) {
        if (typeof action === 'object') {
          this.alias = action.alias
        } else {
          this.alias = action
        }
        if (type) {
          this.getFormData()
          this.alias = "sequence";
          const obj = JSON.parse(JSON.stringify(this.nextNode))
          this.taskSequenceForm.taskTitle = this.task.taskTitle;

          var sequenceNode = [];
          obj.forEach((item, index, array) => {
            //执行代码
            if (item.taskId == action.targetRef) {
              sequenceNode.push(item);

            }
          })
          this.sequenceNode = sequenceNode;

          this.handlerSequenceModel = true;
        } else {
          switch (this.alias) {
            case 'agree':// 普通任务正常办理

              this.task.action = 'agree'
              this.task.actionName = 'agree'
              this.task.formType = 'inner'
              this.getFormData()
              this.getBpmVarList()
              this.handlerModel = true
              break
            case 'pass':// 多实例通过

              this.task.action = 'pass'
              this.task.actionName = 'pass'
              this.task.formType = 'inner'
              this.getFormData()
              this.handlerModel = true
              break
            case 'unPass':// 多实例不通过

              this.task.action = 'unPass'
              this.task.actionName = 'unPass'
              this.task.formType = 'inner'
              this.getFormData()
              this.handlerModel = true
              break
            case 'informed':
              this.informed.informed = true
              break
            case 'agreeAdHocSubProcess':
              this.getFormData()
              this.agreeAdHocSubProcess.show = true;
              break
            case 'transferTask':
              this.transferTask.model = true
              break
            case 'invalid':
              this.invalidTaskAction()
              break
            case 'headmap':
              this.headMapAction()
              break
            case 'flowImage':
              this.flowImageAction()
              break
            case 'approvalHistory':
              this.opinionAction()
              break
            case 'transactionUrge':

              this.transactionUrgeAction()
              break
            case 'addNode':
              this.addNodeAction()
              break
            case 'addSignNode':

              this.addSignNode()
              break
            case 'saveDraft':
              this.saveAction()
              break
            case 'backToNode':

              this.backToNodeAction()
              break
            case 'print':

              window.print()
              break
            case 'addUser':

              this.addUserTask.model = true
              break
            case 'revisit':
              var    url = process.env.VUE_APP_BASE_BPM_API + "revisit/viewer.html" + "?t=" + new Date().getTime()+"&taskId="+this.taskId;
              this.revisit.modelerSrc = url
              this.revisit.model = true
              break
            case 'flw_fawen_add'://发文下发任务
              var taskId=  this.task.taskId;
              this.faWenAddForm.taskId=taskId
              getNextNodeFaWen(taskId).then(res => {
                if (res && res.code==0){
                  this.faWenAddForm.sequenceNode=res.data
                  this.faWenAdd.model = true

                }
              })
                .catch(() => {

                })

              break
            case 'flw_fawen_agree'://发文下办理
              var taskId=  this.task.taskId;
              completeActivity(taskId).then(res => {
                if (res && res.code==0){
                  this.$message({"duration": '800', message: '操作成功', type: 'success', customClass: 'zZindex'});



                }else{

                }
                this.go()
              })
                .catch(() => {

                })

              break
            case 'flw_fawen_target_only'://发文下办理
              var taskId=  this.task.taskId;
              completeActivityOrNo(taskId).then(res => {
                if (res && res.code==0){
                  this.$message({"duration": '800', message: '操作成功', type: 'success', customClass: 'zZindex'});



                }else{

                }
                this.go()
              })
                .catch(() => {

                })

              break
            case 'flw_fawen_target_sign_only'://发文下办理
              var taskId=  this.task.taskId;
              completeActivitySignOnly(taskId).then(res => {
                if (res && res.code==0){
                  this.$message({"duration": '800', message: '操作成功', type: 'success', customClass: 'zZindex'});



                }else{

                }
                this.go()
              })
                .catch(() => {

                })

              break
            default:
              this.task.action = 'agree'
              this.task.actionName = 'agree'
              this.task.formType = 'inner'
              this.getFormData()
              this.handlerModel = true
          }
        }


      },
      backToNodeAction: function () {
        getBackNode(this.taskId).then((response) => {
          if (response.code == 0) {
            this.backToNodeForm.nodeArray = response.data
          }
          this.backToNodeForm.show = true
        })
        this.backToNodeForm.taskTitle = this.task.taskTitle
        // getBackNode
      },
      saveAction: function () {
        var obj = {}
        obj['taskId'] = this.taskId
        const that = this
        this.getFormData()
        setTimeout(function () {
          var formData = that.task.formData
          obj['formData'] = formData
          saveform(obj).then((response) => {
            if (response.code == 0) {
              that.$message({"duration": '800', message: '保存成功', type: 'success', customClass: 'zZindex'});


            }
          })
        }, 300)
      },
      addNodeAction: function () {
        this.handleReset('addNode')
        getOutgoingFlows(this.taskId).then((response) => {
          if (response.code == 0) {
            this.transactionUrgeData.nodeArray = response.data
            this.transactionUrge.taskTitle = this.task.taskTitle
            this.addNode.show = true

          }
        })

      },
      addSignNode: function () {
        this.handleAddSignReset()
        getOutgoingFlows(this.taskId).then((response) => {
          if (response.code == 0) {
            this.transactionUrgeData.nodeArray = response.data
            this.transactionUrge.taskTitle = this.task.taskTitle
            this.addSign.show = true
          }
        })
      },
      transactionUrgeAction: function () {
        getTransactionUrge(this.taskId).then((response) => {
          if (response.code == 0) {
            this.transactionUrgeData.nodeArray = response.data
            this.transactionUrge.taskTitle = this.task.taskTitle
            this.transactionUrge.show = true
          }
        })
      },
      opinionAction: function () {
        this.opinion.show = true
        opinionTask(this.processInstanceId).then((response) => {
          if (response.code == 0) {
            this.opinion.tableData = response.data
          }
        })
      },
      headMapAction: function () {
        var url = this.headMap.base + this.processDefinitionId + '&t=' + new Date().getTime();
        this.headMap.src = url
        this.headMap.show = true
      },
      flowImageAction: function () {
        var url = this.flowImage.base + this.processInstanceId + '&t=' + new Date().getTime();
        this.flowImage.src = url;
        this.flowImage.show = true
      },
      invalidTaskAction: function () {
        invalidTask(this.taskId).then((response) => {
          if (response.code == 0) {
            this.$message({"duration": '800', message: '作废成功', type: 'success', customClass: 'zZindex'});

            const that = this
            setTimeout(function () {
              that.go()
            }, 300)
          }
        })
      },
      go: function () {
        this.handlerModel = false

        if (Boolean(this.monitor)) {
          //流程监控过来的
          this.$store.dispatch('tagsView/delView', this.$route)
          this.$router.push({name: 'cockpitTaskIndex', query: {t: new Date().getTime()}})
          return
        }
        // 调用全局挂载的方法
        if (this.fromIndex) {
          //首页过来的
          this.jsonData = {}
          this.editData = {}
          this.fromIndex = false;
          this.$emit('closeEvent', true)
        } else {

          this.$store.dispatch('tagsView/delView', this.$route)
          this.$router.push({name: 'myTask', query: {t: new Date().getTime()}})
        }

      },
      getNextNode: function () {
        getNextNode(this.taskId).then((response) => {
          if (response.code == 0) {
            this.nextNode = response.data
            this.task.nextNode = response.data
            this.existData = [];
            this.existData = this.task.nextNode
            this.agreeAdHocSubProcess.nextNode = response.data;
            var data = response.data;
            var nextNodeName = [];
            var nextNodeNameOptions = [];
            for (let i = 0; i < data.length; i++) {
              var d = data[i];
              nextNodeName.push(d.taskName)
              nextNodeNameOptions.push(d.taskName)

            }
            this.agreeAdHocSubProcess.nextNodeName = nextNodeName;
            this.agreeAdHocSubProcess.nextNodeNameOptions = nextNodeNameOptions;
            if (this.nextNode.length == 0) {
              this.nextNode.push({
                "taskId": "",
                "taskName": "等待其他任务汇总",
                "nodeType": "userTask",
              });
            }

          }
        })
      },
      renderAttachmentByTaskId: function (id) {
        try {
          this.attachmentForm.taskId = id;
          renderAttachmentByTaskId(id).then((response) => {
            if (response.code == 0) {
              var data = response.data;
              this.bpmTaskAttachment = data;
              if (response.bpmTaskAttachment) {
                this.attachmentForm.id = response.bpmTaskAttachment.id;
                this.attachmentForm.createBy = response.bpmTaskAttachment.createBy
                this.attachmentForm.createTime = response.bpmTaskAttachment.createTime
                this.attachmentForm.procDefId = response.bpmTaskAttachment.procDefId
                this.attachmentForm.changeContent = response.bpmTaskAttachment.changeContent
                this.attachmentForm.taskId = response.bpmTaskAttachment.taskId
                this.attachmentForm.processInstanceId = response.bpmTaskAttachment.processInstanceId
                this.fileList = response.bpmTaskAttachment.bpmTaskAttachmentDetailedList
              }
            } else {
            }
          })
        } catch (e) {

        }
      },
      renderApproval: function () {
        try {
          getApprovalOfMe().then((response) => {
            if (response.code == 0) {
              var data = response.data;
              this.approval=data;

            } else {
            }
          })
        } catch (e) {

        }
      },
      renderByTaskId: function (id) {
        try {
          renderByTaskId(id).then((response) => {
            if (response.code == 0) {
              if (response.data) {
                this.jsonData = JSON.parse(response.data)
              }
              if (response.editData) {
                this.editData = JSON.parse(response.editData)

              }
            } else {
              this.go()
            }
          })
        } catch (e) {

        }
      },
      renderBpmTaskAttachment: function (processInstanceId) {
        var url = this.flowImage.base + processInstanceId + '&t=' + new Date().getTime();
        this.viewImageModelerTmpSrc = url;
      },
      getFlowProcess(id){
        getProcess(id).then((response) => {
          if (response.code == 0) {
            this.wkFlowList = response.data
          }
        });
      },
      getTaskBtn: function (id) {
        try {
          getTaskBtn(id).then((response) => {
            if (response.code == 0) {
              this.taskBtns = response.data
              this.multiInstanceTaskBtns = response.multiInstance
              this.taskSequence = response.sequence
              this.isSpinShow = false
              var taskTitle = response.taskTitle
              var processDefinitionId = response.processDefinitionId
              this.processDefinitionId = processDefinitionId
              var processInstanceId = response.processInstanceId
              if (processInstanceId) {
                this.renderBpmTaskAttachment(processInstanceId)
              }
              this.processInstanceId = processInstanceId
              this.task.taskTitle = taskTitle
              this.tmpTaskInfo.taskTitle = taskTitle
              this.informed.taskTitle = taskTitle
              this.agreeAdHocSubProcess.taskTitle = taskTitle
            } else {
              this.go()
            }
          })
        } catch (e) {
          this.go()
        }
      }

    }

  }

</script>
<style lang="scss" scoped>
   /deep/ .el-dialog__header {
    border-bottom: 1px solid #ebebeb;
  }
   /deep/   .el-dialog__footer {
     border-top: 1px solid #e8eaec;
   }

  .xr-btn--green {
    background-color: #389E0B;
    border-color: #389E0B;

    i {
      font-size: 13px;
      margin-right: 5px;
    }
  }

  .xr-btn--green:hover,
  .xr-btn--green.is-disabled,
  .xr-btn--green.is-disabled:hover,
  .xr-btn--green:focus {
    background: #4ca824;
    border-color: #4ca824;
    color: #FFFFFF;
  }
  // 拒绝红
  .xr-btn--red {
    background-color: #f94e4e;
    border-color: #f94e4e;

    i {
      font-size: 13px;
      margin-right: 5px;
    }
  }

  .xr-btn--red:hover,
  .xr-btn--red.is-disabled,
  .xr-btn--red.is-disabled:hover,
  .xr-btn--red:focus {
    background: #fa6060;
    border-color: #fa6060;
    color: #FFFFFF;
  }

  // 按钮橙黄
  .xr-btn--orange {
    background-color: #ff6a00;
    border-color: #ff6a00;

    i {
      font-size: 13px;
      margin-right: 5px;
    }
  }

  .xr-btn--orange:hover,
  .xr-btn--orange.is-disabled,
  .xr-btn--orange.is-disabled:hover,
  .xr-btn--orange:focus {
    background: #fc7d63;
    border-color: #fc7d63;
    color: #FFFFFF;
  }
  .task-card {
    margin-top: 10px;
  }

  .container {
    height: auto !important;
    min-height: 450px;
  }

  .zZindex {
    z-index: 3000 !important;
  }

</style>
